//
//  DBParserRuleTerminal.m
//  parser
//
//  Created by Daniel Braun on 26/05/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "DBParserRuleTerminal.h"
#import "DBParser.h"
#import "DBLexer.h"

@implementation DBParserRuleTerminal

- (DBParserRule *) setTerminal:(int)tokenNum
{
	tokens[0]=tokenNum;
	return self;
}

+ (id) terminalRule:(int)t action:(SEL)act
{
	id rul=[[[[self class]alloc]initWithAction:act]autorelease];
	[rul setTerminal:t];
	return rul;
}

- (void) invokeWithParser:(DBParser *)p
{
	int tok=[[p _lookAhead0]tokval];
	if (tok==tokens[0]) {
		[self beginWithParser:p];
		[self matchedWithParser:p consume:YES];
	} else {
		[p _nomatch:self];
	}
}

- (void) preProcess
{
	[nextSeq preProcess];
}

- (NSString *) description
{
	return [NSString stringWithFormat:@"RULE terminal %d", tokens[0]];
}


@end
